<?php

namespace app\health\model;

use think\Model;
use think\model\relation\BelongsTo;

class HealthUserServeRecord extends Model
{
    public const SERVICE_TYPE_MAP = [
        1  => '图文问诊',
        2  => '视频问诊',
        3  => '挂号',
        4  => '二诊',
        5  => '中医问诊',
        6  => '陪诊',
        7  => '住院',
        8  => '健康档案及体检报告解读',
        9  => '营养师咨询',
        10 => '私教咨询服务',
        11 => '私教',
        12 => '单程上门接送',
        13 => '双程上门接送',
        14 => '点诊挂号',
        15 => '门诊就医协助',
        16 => '点诊大咖专家',
        17 => '普通就医陪诊',
        18 => '家庭医生',
        19 => '优惠券',
    ];

    protected $append = ['service_type_txt'];

    /**
     * 获取服务类型描述
     * @param $val
     * @param $data
     * @return string
     */
    public function getServiceTypeTxtAttr($val, $data): string
    {
        return self::SERVICE_TYPE_MAP[$data['service_type']] ?? '-';
    }

    /**
     * 关联用户信息
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(HealthUser::class, 'user_id');
    }
}